import asyncio

import aiohttp

from chapter01.asyncio.utils import take_up_time


async def request_async(session, url='https://www.baidu.com'):
    async with session.get(url) as resp:
        return await resp.text()


async def run():
    async with aiohttp.ClientSession() as session:
        tasks = [asyncio.create_task(request_async(session)) for _ in range(0, 49)]
        await asyncio.gather(*tasks)


@take_up_time
def main():
    asyncio.run(run())


if __name__ == '__main__':
    main()
